package hu.gar.core.service.impl;

import java.util.List;

import hu.gar.common.service.RoleService;
import hu.gar.core.dao.RoleDao;
import hu.gar.vo.RoleVO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("roleService")
@Transactional(propagation = Propagation.REQUIRED)
public class RoleServiceImpl implements RoleService {

	private static final long serialVersionUID = -4824868943588512027L;

	@Autowired
	RoleDao roleDao;

	@Override
	public RoleVO createRole(RoleVO roleVO) {
		return roleDao.toVO(roleDao.create(roleDao.toEntity(roleVO)));
	}

	@Override
	public RoleVO getRoleByName(String name) {
		return roleDao.toVO(roleDao.findByName(name));
	}

	@Override
	public List<RoleVO> getAllRole() {
		return roleDao.toVO(roleDao.findAll());
	}

}
